//
//  YNSOutView.m
//  HNBaseProject
//
//  Created by TR on 2024/7/22.
//

#import "YNSOutView.h"

@implementation YNSOutView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame])
    {
        self.backgroundColor = RGBA_COLOR(0, 0, 0, 0.4);
        
        self.bgView = [[UIView alloc]init];
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius=19;
        [self addSubview:self.bgView];
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX).offset(0);
            make.centerY.equalTo(self.mas_centerY).offset(0);
            make.width.offset(kScreenW-60);
            make.height.offset(kRealValue(281));
        }];
        CAGradientLayer *gl = [CAGradientLayer layer];
        gl.frame = CGRectMake(0,0,kScreenW-60,kRealValue(281));
        gl.startPoint = CGPointMake(0.5, 0);
        gl.endPoint = CGPointMake(0.5, 1);
        gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#DBEDFF"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#FFFFFF"].CGColor];
        gl.locations = @[@(0), @(1.0f)];
        [self.bgView.layer addSublayer:gl];
        
        self.tLab1 = [[UILabel alloc]init];
        self.tLab1.text = [NSString stringWithFormat:@"====== %@ ======",NSLocalizedString(@"确定现在就要离开吗?", nil)];
        self.tLab1.textColor = [UIColor colorWithHexString:@"#333333"];
        self.tLab1.font = PFRFontMedium(15);
        [self.bgView addSubview:self.tLab1];
        [self.tLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.bgView.mas_centerX).offset(0);
            make.top.offset(24);
        }];
        
//        self.tLab2 = [[UILabel alloc]init];
//        self.tLab2.text = NSLocalizedString(@"离开后可在", nil);//@"离开后可在";
//        self.tLab2.textColor = [UIColor colorWithHexString:@"#666666"];
//        self.tLab2.font = PFRFont(16);
//        [self.bgView addSubview:self.tLab2];
//        [self.tLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.equalTo(self.bgView.mas_centerX).offset(0);
//            make.top.equalTo(self.tLab1.mas_bottom).offset(38);
//        }];
//        
        self.tLab3 = [[UILabel alloc]init];
        self.tLab3.text =  NSLocalizedString(@"返回不会影响制作，稍后可以在首页-我的制作-历史制作里面查看。", nil);//@"";
        self.tLab3.textColor = [UIColor colorWithHexString:@"#1D8EFF"];
        self.tLab3.font = PFRFontSemibold(20);
        self.tLab3.numberOfLines = 0;
        [self.bgView addSubview:self.tLab3];
        [self.tLab3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(self.bgView);
            make.left.offset(20);
            make.right.offset(-20);
        }];
//        
//        self.tLab4 = [[UILabel alloc]init];
//        self.tLab4.text = NSLocalizedString(@"获得制作好的视频材料", nil);//@"";
//        self.tLab4.textColor = [UIColor colorWithHexString:@"#666666"];
//        self.tLab4.font = PFRFont(16);
//        [self.bgView addSubview:self.tLab4];
//        [self.tLab4 mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.equalTo(self.bgView.mas_centerX).offset(0);
//            make.top.equalTo(self.tLab3.mas_bottom).offset(10);
//        }];
        
        self.cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.cancelBtn setTitle:NSLocalizedString(@"继续等待", nil) forState:UIControlStateNormal];
        [self.cancelBtn setTitleColor:[UIColor colorWithHexString:@"#7D7C81"] forState:UIControlStateNormal];
        self.cancelBtn.backgroundColor = [UIColor whiteColor];
        self.cancelBtn.layer.masksToBounds = YES;
        self.cancelBtn.layer.cornerRadius = 21;
        self.cancelBtn.layer.borderColor = [UIColor colorWithHexString:@"#CCCCCC"].CGColor;
        self.cancelBtn.layer.borderWidth = 1;
        self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.cancelBtn addTarget:self action:@selector(cancelClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.cancelBtn];
        [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(24);
//            make.top.equalTo(self.tLab4.mas_bottom).offset(38);
            make.bottom.offset(-30);
            make.width.offset((kScreenW-120)/2);
            make.height.offset(42);
        }];
        
        self.comfireBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.comfireBtn setTitle:NSLocalizedString(@"确认离开", nil) forState:UIControlStateNormal];
        [self.comfireBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
        self.comfireBtn.backgroundColor = [UIColor colorWithHexString:@"#1D8EFF"];
        self.comfireBtn.layer.masksToBounds = YES;
        self.comfireBtn.layer.cornerRadius = 21;
        self.comfireBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.comfireBtn addTarget:self action:@selector(comfireClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.comfireBtn];
        [self.comfireBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-24);
            make.bottom.offset(-30);
            make.width.offset((kScreenW-120)/2);
            make.height.offset(42);
        }];
    }
    return self;
}

#pragma mark------cancelClick------
- (void)cancelClick{
    [self removeFromSuperview];
}

#pragma mark------comfireClick------
- (void)comfireClick{
    if (self.comfireblock) {
        self.comfireblock();
    }
}

@end
